# Contributor: Alex Denes <caskd@redxen.eu>
# Maintainer: Alex Denes <caskd@redxen.eu>
pkgname=prometheus-json-exporter
_pkgname=json_exporter
pkgver=0.4.0
pkgrel=3
pkgdesc="Prometheus exporter which scrapes remote JSON by JSONPath"
url="https://github.com/prometheus-community/json_exporter"
license="Apache-2.0"
arch="all !riscv64" # nonexistent riscv64 dependency downloaded at build time
makedepends="go>=1.14 bash sed"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="$pkgname-openrc"
source="$_pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz
	json-exporter.initd
	json-exporter.confd
	0001-disable-go-race-detector.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"
export GOFLAGS="$GOFLAGS -modcacherw"

build() {
	make build
}

check() {
	make test
}

package() {
	install -Dm755 json_exporter "$pkgdir"/usr/bin/json_exporter

	install -Dm755 "$srcdir"/json-exporter.initd "$pkgdir"/etc/init.d/json-exporter
	install -Dm644 "$srcdir"/json-exporter.confd "$pkgdir"/etc/conf.d/json-exporter
}

sha512sums="
43d4a141fc0771ca4105502b7e5c37acd599287145e958206b1e5c853df87b22a828a4bb63c9056350da3e06c448a05f136896ae536239d6715325c54426d71d  json_exporter-0.4.0.tar.gz
ebed56a4b890d8c4407414befb75ec1ce12ea9af495a90e6a92e8f51ed2c5682c04bf264c0ef8e43dd4375f3418bd72f4d86a9bbfa546405acdcbe4def9c87cf  json-exporter.initd
2fecc0fdf9da9179ad24c14651efec341fccf3747d4570fe0ca5e1f5db1eb7ec49ce84add28d2804c03c95acd9762a660dfe5577fe26265ef35a82fa9c455aad  json-exporter.confd
0e916a9216fbf21865a3672a1159836993048de1112dc8ddbd4e8283264d7fe12c5a5e2b08adeced2db6d4d35feb799c59eae7e55d010d045e825b4a524ae5e2  0001-disable-go-race-detector.patch
"
